package com.ruoyi.common.core.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.domain.MerchantVerification;
import com.ruoyi.common.core.service.IMerchantVerificationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商户排名Controller
 * 
 * @author ruoyi
 * @date 2025-11-12
 */
@RestController
@RequestMapping("/merchantRank")
public class MerchantVerificationController extends BaseController
{
    @Autowired
    private IMerchantVerificationService merchantVerificationService;

    /**
     * 查询商户排名列表
     */

    @GetMapping("/list")
    public TableDataInfo list(MerchantVerification merchantVerification)
    {
        startPage();
        List<MerchantVerification> list = merchantVerificationService.selectMerchantVerificationList(merchantVerification);
        return getDataTable(list);
    }

    /**
     * 导出商户排名列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, MerchantVerification merchantVerification)
    {
        List<MerchantVerification> list = merchantVerificationService.selectMerchantVerificationList(merchantVerification);
        ExcelUtil<MerchantVerification> util = new ExcelUtil<MerchantVerification>(MerchantVerification.class);
        util.exportExcel(response, list, "商户排名数据");
    }

    /**
     * 获取商户排名详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(merchantVerificationService.selectMerchantVerificationById(id));
    }

    /**
     * 新增商户排名
     */

    @PostMapping
    public AjaxResult add(@RequestBody MerchantVerification merchantVerification)
    {
        return toAjax(merchantVerificationService.insertMerchantVerification(merchantVerification));
    }

    /**
     * 修改商户排名
     */

    @PutMapping
    public AjaxResult edit(@RequestBody MerchantVerification merchantVerification)
    {
        return toAjax(merchantVerificationService.updateMerchantVerification(merchantVerification));
    }

    /**
     * 删除商户排名
     */

	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(merchantVerificationService.deleteMerchantVerificationByIds(ids));
    }
}
